←Select platform

WindowLevelCommand Constructor(int,int,RasterColor[],RasterByteOrder)

Summary
Initializes a new WindowLevelCommand class object with explicit parameters.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (instancetype)initWithLookupTable:(NSArray<LTRasterColor *> *)lookupTable lowBit:(NSInteger)lowBit highBit:(NSInteger)highBit order:(LTRasterByteOrder)order NS_DESIGNATED_INITIALIZER; 
public WindowLevelCommand( 
   int lowBit, 
   int highBit, 
   RasterColor[] lookupTable, 
   RasterByteOrder order 
); 
public: 
WindowLevelCommand(  
   int lowBit, 
   int highBit, 
   array<RasterColor>^ lookupTable, 
   RasterByteOrder order 
) 
__init__(self,lowBit,highBit,lookupTable,order) # Overloaded constructor 

Parameters

lowBit
Value indicating the low bit used for leveling. 0 <= lowBit <= highBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).

highBit
Value indicating the high bit used for leveling. 0 <= lowBit <= highBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).

lookupTable
Optional 8-bit lookup table that can be used to implement a user defined conversion. For every intensity value between 0 and 2 raised to the power of (highBit - lowBit + 1) - 1 there should be a corresponding entry in the lookup table that contains an RGB quad. If lookupTable is null, the conversion is a normal shift (right or left) and the output image is 8-bit grayscale. If lookupTable is not null, the output image is a 24-bit image.

order
Value indicating the color order if the output image will be 24-bit. If LookupTable is null, this parameter is ignored.

Example

Run the WindowLevelCommand on an image.

C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
 
public void WindowLevelConstructorExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm")); 
 
   // Prepare the command 
   //Change the image to 16-bit grayscale 
   GrayscaleCommand graycommand = new GrayscaleCommand(16); 
   graycommand.Run(image); 
 
   MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); 
   MinMaxBits.Run(image); 
 
   MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); 
   MinMaxValues.Run(image); 
 
   int Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); 
   RasterColor[] LookupTable = new RasterColor[Size]; 
 
   // fill the first half of the LookupTable with RED. 
   for (int x = 0; x < Size / 2; x++) 
      LookupTable[x] = new RasterColor(255, 0, 0); 
 
   // fill the rest with gray values. 
   for (int x = Size / 2; x < Size; x++) 
   { 
      byte y = (byte)((x - MinMaxValues.MinimumValue) * 255 / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); 
      LookupTable[x] = new RasterColor(y, y, y); 
   } 
 
   WindowLevelCommand command = new WindowLevelCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr); 
 
   command.Run(image); 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.*; 
import leadtools.imageprocessing.core.*; 
 
 
public void windowLevelConstructorExample() { 
 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.setThrowExceptionsOnInvalidImages(true); 
 
   RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "DICOM\\IMAGE3.dcm")); 
 
   // Prepare the command 
   // Change the image to 16-bit grayscale 
   GrayscaleCommand grayCommand = new GrayscaleCommand(16); 
   grayCommand.run(image); 
 
   MinMaxBitsCommand minMaxBits = new MinMaxBitsCommand(); 
   minMaxBits.run(image); 
 
   MinMaxValuesCommand minMaxValues = new MinMaxValuesCommand(); 
   minMaxValues.run(image); 
 
   int size = (1 << (minMaxBits.getMaximumBit() - minMaxBits.getMinimumBit() + 1)); 
   RasterColor[] lookupTable = new RasterColor[size]; 
 
   // fill the first half of the LookupTable with RED. 
   for (int x = 0; x < size / 2; x++) 
      lookupTable[x] = new RasterColor(255, 0, 0); 
 
   // fill the rest with gray values. 
   for (int x = size / 2; x < size; x++) { 
 
      byte y = (byte) ((x - minMaxValues.getMinimumValue()) * 255 
            / (minMaxValues.getMaximumValue() - minMaxValues.getMinimumValue())); 
      lookupTable[x] = new RasterColor(y, y, y); 
 
   } 
 
   WindowLevelCommand command = new WindowLevelCommand(minMaxBits.getMinimumBit(), minMaxBits.getMaximumBit(), 
         lookupTable, RasterByteOrder.BGR); 
 
   int change = command.run(image); 
   assertTrue(change != RasterImageChangedFlags.NONE); 
 
   codecs.save(image, combine(LEAD_VARS_IMAGES_DIR, "Result.jpg"), RasterImageFormat.JPEG, 24); 
   System.out.println("Command run, image saved to " + combine(LEAD_VARS_IMAGES_DIR, "Result.jpg")); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.3.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Core Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.